#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    char ch;
    int count=0;
    getline(cin,str);
    cin >> ch;
    if(ch>='A'&&ch<='Z') ch+=32;
    auto it=str.begin();
    while(it!=str.end())
    {
        if(*it>='A'&&*it<='Z') *it+=32;
        if(ch==*it) count++;
        ++it;
    }
    cout<< count;
    return 0;
}